<?php
/**
 * @author 	Vu Nhat Lam
 * 			Mail: lamvnd@gmail.com
 * 			Mobile: 0984 52 62 68
 * @version 1.0.0
 */
error_reporting(0);
ignore_user_abort(true);
@set_time_limit(0);

// ########################## REQUIRE BACK-END ############################
require_once('./global.php');

// Passkey generation
do
{
	$db->query_write("
		UPDATE `". TABLE_PREFIX ."user`
		SET `passkey` = '" . fetch_random_string() . "'
		WHERE `passkey` IS NULL OR `passkey` = '' LIMIT 1");
}
while (mysql_affected_rows());

// Alter table `user`
$db->query_write("
	ALTER TABLE `" . TABLE_PREFIX . "user` DROP INDEX passkey
");

$db->query_write("
	ALTER TABLE `" . TABLE_PREFIX . "user`
		ADD UNIQUE KEY `passkey` (`passkey`)
");

echo '<p>Repair passkey <b>DONE</b></p>';
